#include <stdio.h>
#include <stdlib.h>
void stonesCollision(int* stones, int stonesSize){
    int count = -1;
    for (int i = 0; i < stonesSize; i++) {
        if (count < 0 || stones[count] < 0) {  
            stones[++(count)] = stones[i];
            continue;
        }
        if (stones[i] > 0) {             
            stones[++(count)] = stones[i];  
            continue;
        } else if (stones[count] < abs(stones[i])) {   
            (count)--;
            i--;
        } else if (stones[count] == abs(stones[i])) {   
           (count)--;
        }
    }
    (count)++;
    for(int i = 0; i < count; i++)
        printf("%d ", stones[i]);
    return;
}
int main(){
    int stonesSize;
    int* stones = NULL;
    scanf("%d", &stonesSize);
    stones = (int*)calloc(stonesSize, sizeof(int));
    for(int i = 0; i < stonesSize; i++)
        scanf("%d", &stones[i]);
    stonesCollision(stones, stonesSize);
    free(stones);
    return 0;
}
